clear all
set more off
cd "/Users/yasenov/Dropbox/mariel_boatlift/jhr_version/jhr_figures"
global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/
set scheme s1color

use $folder/aux_may-org.dta

keep if low_skilled == 1
drop if (ftpt79 == 0 & year <= 1988) | (ftpt89 ==1 & year > 1988)
keep if classer == 1 | classer == 2
keep if age >= 25 & age <= 59
keep if ethnic == 8
keep if male == 1
keep if logearnwke > 0

collapse (mean) loguearnhre logearnwke [pw=earnwt], by(year smsarank)

reshape wide loguearnhre logearnwke, i(year) j(smsarank)
rename ( loguearnhre26 logearnwke26) ( loguearnhre_mia logearnwke_mia)

******************************
/* Borjas '77-'79 Synthetic Control */
******************************
* See Appendix Table A1 in Borjas 2015 (i.e., first paper)
gen loguearnhre_bor_7779 = .296 * loguearnhre24 + .497 * loguearnhre19 + .207 * loguearnhre38
gen logearnwke_bor_7779 = .296 * logearnwke24 + .497 * logearnwke19 + .207 * logearnwke38

******************************
/* Our Synthetic Control */
******************************
/* merge 1:1 year smsarank using $folder/msa_controls_may-org.dta, nogenerate
xtset smsa year
local controls loguearnhre low_skilled hisp manuf
synth loguearnhre `controls', trunit(26) trperiod(1980) nested fig
local controls logearnwke low_skilled hisp manuf
synth logearnwke `controls', trunit(26) trperiod(1980) nested fig */

gen loguearnhre_our = .246 * loguearnhre21 + .158 * loguearnhre33 + .596 * loguearnhre57
gen logearnwke_our = .639 * logearnwke57 + .318 * logearnwke33 + .043 * logearnwke45

******************
/* Graphing */
******************
local vars loguearnhre_bor_7779 loguearnhre_our

foreach i of local vars {
	scalar a`i' = loguearnhre_mia[7] - `i'[7]
	replace `i' = `i' + a`i'
	}

local vars logearnwke_bor_7779 logearnwke_our

foreach i of local vars {
	scalar a`i' = logearnwke_mia[7] - `i'[7]
	replace `i' = `i' + a`i'
	}
	
twoway (line loguearnhre_mia year, lcolor(black) lpattern(solid)) ///
	(line loguearnhre_our year, lcolor(black) lpattern(dash)) ///
	(line loguearnhre_bor_7779 year, lcolor(black) lpattern(dot) lwidth(thick)), ///
	xline(1979, lpattern(dash) lcolor(black)) ///
	xtitle("") ///
	ytitle("") ///
	subtitle("Log Hourly Wages, May+ORG CPS, Borjas (2017) Sample") ///
	legend(off) ///
	xlabel(1973 "1973" 1975 "75" 1977 "77" 1979 `""79" "Pre""' 1981 `""81" "Post""' 1983 "83" 1985 "85" 1987 "87" 1989 "89" 1991 "91") ///
	xscale(range(1972 1992))  plotregion(lwidth(none)) ///
	yscale(range(1.4 2.1)) ylabel(1.4(.2)2.1) ///
	text(2.1 1990.8 "Panel A")

graph export "jhr_fig9a.pdf", replace	

twoway (line logearnwke_mia year, lcolor(black) lpattern(solid)) ///
	(line logearnwke_our year, lcolor(black) lpattern(dash)) ///
	(line logearnwke_bor_7779 year, lcolor(black) lpattern(dot) lwidth(thick)), ///
	xline(1979, lpattern(dash) lcolor(black)) ///
	xtitle("") ///
	ytitle("") ///
	subtitle("Log Weekly Wages, May+ORG CPS, Borjas (2017) Sample") ///
	legend(on r(1) label(1 "Miami") label(2 "Our Synthetic") label(3 "Borjas Synthetic '77-'79")) ///
	xlabel(1973 "1973" 1975 "75" 1977 "77" 1979 `""79" "Pre""' 1981 `""81" "Post""' 1983 "83" 1985 "85" 1987 "87" 1989 "89" 1991 "91") ///
	xscale(range(1972 1992))  plotregion(lwidth(none)) ///
	yscale(range(5 5.7)) ylabel(5(.2)5.7) ///
	text(5.7 1990.8 "Panel B")

graph export "jhr_fig9b.pdf", replace	
